package com.chunuo.configuration.factory;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 读取（application.properties）配置类
 *
 * @author liujiamiao
 * @email 2544296058@qq.com
 * @date 2020-12-22 11:31
 */
public class PropertiesFile extends Properties {

    private static PropertiesFile propertiesFile;

    private PropertiesFile(){
        InputStream is = this.getClass().getResourceAsStream("/application.properties");
        try {
            load(is);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static PropertiesFile newInstance(){
        if(propertiesFile==null){
            synchronized (PropertiesFile.class){
                if(propertiesFile==null){
                    propertiesFile = new PropertiesFile();
                }
            }
        }
        return propertiesFile;
    }

}
